import { Connection } from 'mongoose';
import { getInstance } from '../../db';
import { videoSchema } from '../../schemas/videoSchema';

// 更新视频相关接口
export async function updateVideoOtherService(params: IAnyObject):Promise<IAnyObject> {
  const db: Connection = await getInstance();

  const { id } = params;

  delete params.id;

  const videoModel = db.model('video', videoSchema);

  const condition = {
    _id: id,
  };

  // 返回更新后的数据
  const result = await videoModel.findOneAndUpdate(condition, { ...params }, { new: true });

  return result;
}
